<script type="text/javascript">
/* function reload(json)
{
	alertMsg.confirm(json.confirmMsg || DWZ.msg("forwardConfirmMsg"), {
		okCall: function(){
			 $.pdialog.reload('__URL__/pay/id/'+{$carrierid}+'/payid/'+{$payid},null,'pay'); //刷新dlid指定的dialog，url：刷新时可重新指定加载数据的url, data：为加载数据时所需的参数。
		}
	});
  
} */
//格式化函数，设置保留位数
function ForDight(Dight,How){  
    Dight = Math.round(Dight*Math.pow(10,How))/Math.pow(10,How);  
    return Dight;  
} 
//浮点计算
function accAdd(arg1,arg2){
    var r1,r2,m;
    try{r1=arg1.toString().split(".")[1].length}catch(e){r1=0}
    try{r2=arg2.toString().split(".")[1].length}catch(e){r2=0}
    m=Math.pow(1000,Math.max(r1,r2))
    return (arg1*m+arg2*m)/m
}
function SelectAll() {
	
	 var checkboxxall=document.getElementById("checkboxxid");
	 var checkboxs=document.getElementsByName("checkboxx[]");
	 for (var i=0;i<checkboxs.length;i++) {
	  var e=checkboxs[i];
	 if(checkboxxall.checked){
        e.checked=true;
	 }else{
		 e.checked=false;
	 }
	  func();
	 }
	}
function func(){
    tbody=document.getElementById("carriertbody");
	objname=document.getElementsByName("checkboxx[]");
	var money=0;
	for(var i=0;i<objname.length;i++)
    {
        if(objname[i].checked)
        {   
        	if(""==tbody.rows[i].cells[7].firstChild.innerHTML){
        		alert("数值为空不能参与计算");
        		objname[i].checked=0;
        	}else{
        		var html=parseFloat(tbody.rows[i].cells[7].firstChild.innerHTML);
        		money=accAdd(money,ForDight(html,4));
        	}
        }
    } 
    var totalment = document.getElementById("totalment");
	totalment.value=money;
}

</script>
<div class="pageContent">
	<form method="post" action="__URL__/insertPay/navTabId/__MODULE__/callbackType/closeCurrent" rel="checkboxx" class="pageForm required-validate" onsubmit="return validateCallback(this, dialogAjaxDone)">
	   <input type="hidden" name="carrierid" value="{$carrierid}"> 
		<input type="hidden" name="payid" value="{$payid}"> 
		<div class="pageFormContent" layoutH="240">
			<div class="unit">
				<label>付款方：</label>
				<input type="text" class="required" id="payer" name="payer" value="{$payer}" alt="请输入付款方">
			</div>
			<div class="unit">
				<label>付款人：</label>
				<input type="text" name="payperson"  id="payperson" value="{$payperson}" />
			</div>
			<div class="unit">
				<label>收款方：</label>
				<input type="text" name="collection" class="required" id="collection" value="{$collection}" alt="请输入收款方">
			</div>
			<div class="unit">
				<label>收款单位：</label>
				<input type="text" name="getunit" id="getunit" value="{$getunit}">
			</div>
			<div class="unit">
				<label>开户银行：</label>
				<input type="text" name="openbank"  id="openbank" value="{$openbank}">
			</div>
			<div class="unit">
				<label>银行帐号：</label>
				<input type="text" name="account"  id="account" value="{$account}">
			</div>
			<div class="unit">
				<label>总金额：</label>
				<input type="text" id="totalment"  name="totalment" value="{$totalment}">
			</div>
			<!--<div class="unit">
				<label>已付款：</label>
				<input type="text"  id="apayment" name="apayment">
			</div>
			<div class="unit">
				<label>未付款：</label>
				<input type="text"  id="wpayment" name="wpayment">
			</div>-->
			<div class="unit">
				<label>付款时间：</label>
				<input type="text" name="paytime"  id="paytime" value="{$paytime}" class="date" /><a class="inputDateButton" href="javascript:;" style="">选择</a>
			</div>
			
			<div class="unit">
				<label>备注：</label>
				<textarea cols="56" rows="3"  id="notes" name="notes">{$notes}</textarea>
			</div>
		</div>
		
		<table class="table" width="100%"  layoutH="250">
		<thead>
		<tr>
		    <th width="20" align="center"><input type="checkbox" id="checkboxxid" class="checkboxCtrl" onclick="SelectAll()"></th>	
			<th width="100" align="center">发货方</th>
			<th width="100" align="center">接货方</th>
			<th width="100" align="center">起始地</th>
			<th width="140" align="center">目的地</th>
			<th width="100" align="center">出厂净重/吨</th>
			<th width="100" align="center">结算净重/吨</th>
			<th width="100" align="center">运费</th>
		</tr>
		</thead>
		<tbody id="carriertbody">
		<define name="number" value="1"/>
		<volist id="vo" name="list">
			<tr target="sid_node" rel="{$vo['id']}">
				<!-- <td><a href="__URL__/index/id/{$vo['id']}/" target="navTab" rel="__MODULE__">{$vo['carriername']}</a></td> -->
				<td><input type="checkbox" name="checkboxx[]" value="{$vo['id']}" onclick="func()" /></td>
				<td>{$vo['sendername']}</td>
				<td>{$vo['providername']}</td>
				<td>{$vo['beginning']}</td>
				<td>{$vo['destination']}</td>
				<td>{$vo['cweight']}</td>
				<td>{$vo['uweight']}</td>
				<td>{$vo['freight']}</td>
				<!--  <td>{$vo['uweight']}</td>
				<td>{$vo['uloader']}</td>
				<td>{$vo['uloadtime']}</td>-->
				<!-- <td><eq name="vo.status" value="0"><a class="delete"  href='__URL__/checked/ids/{$vo['id']}/id/{$payid}'  target="ajaxTodo" callback="reload" title="你确定要结算吗？">结算</a></eq></td>
		        -->
		</volist>
		</tbody>
	</table>
	
		<div class="formBar">
			<ul>
				<li><div class="buttonActive"><div class="buttonContent"><button type="submit">结算</button></div></div></li>
				<li><div class="button"><div class="buttonContent"><button type="button" class="close">取消</button></div></div></li>
			</ul>
		</div>
		
		
		
	</form>
	
	
	

</div>

